package com.exam.bean;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 * 用户实体 2012-12-03
 * 
 * @author MuLing
 * 
 */
@Entity
@Table(name = "tb_user")
public class User implements Serializable {

	private static final long serialVersionUID = 1L;

	@Id
	// 指定为主键
	@GeneratedValue(strategy = GenerationType.AUTO)
	// 主键类型为自增长
	private Integer id;// 主键id

	@Column(name = "u_userID", length = 30, unique = true)
	// 指定数据库表对应列的名称
	private String userID;// 用户名
 
	@Column(name = "u_password", length = 50) 
	private String password;// 用户密码

	@Column(name = "u_identity")
	private Integer identity = -1;// 用户身份标识

	@Column(name = "u_name", length = 20)
	private String name;// 用户姓名

	@Column(name = "u_sex")
	private boolean sex;// 性别（true表示男、false表示女）

	@Temporal(TemporalType.DATE)
	@Column(name = "u_birthday")
	private Date birthday;// 用户生日

	@Column(name = "u_email", length = 30, unique = true)
	private String email;// 用户注册邮箱

	@Temporal(TemporalType.TIMESTAMP)
	// 日期类型（DATE，TIME还是TIMESTEMP）
	@Column(name = "u_createDateTime")
	private Date createDateTime;// 创建日期

	@Temporal(TemporalType.TIMESTAMP)
	// 日期类型（DATE，TIME还是TIMESTEMP）
	@Column(name = "u_lastLoginDateTime")
	private Date lastLoginDateTime;// 最后一次登录时间

	@Column(name = "u_status")
	private boolean status;// 用户状态、是否可用

	@Column(name = "u_ip")
	private String ip;// 用户的ip

	/**
	 * 无参构造方法
	 */
	public User() {
	}

	/**
	 * 带参数的构造函数
	 * 
	 * @param id
	 *            主键
	 * @param userID
	 *            用户名
	 * @param password
	 *            密码
	 * @param identity
	 *            身份标识
	 * @param name
	 *            真实姓名
	 * @param sex
	 *            性别
	 * @param birthday
	 *            生日
	 * @param email
	 *            邮箱
	 * @param createDateTime
	 *            创建时间
	 * @param lastLoginDateTime
	 *            最近登录时间
	 * @param status
	 *            用户状态
	 * @param ip
	 *            用户ip
	 */
	public User(Integer id, String userID, String password, Integer identity,
			String name, boolean sex, Date birthday, String email,
			Date createDateTime, Date lastLoginDateTime, boolean status,
			String ip) {
		super();
		this.id = id;
		this.userID = userID;
		this.password = password;
		this.identity = identity;
		this.name = name;
		this.sex = sex;
		this.birthday = birthday;
		this.email = email;
		this.createDateTime = createDateTime;
		this.lastLoginDateTime = lastLoginDateTime;
		this.status = status;
		this.ip = ip;
	}

	/**
	 * 取得主键ID
	 * 
	 * @return 返回主键ID
	 */
	public Integer getId() {
		return id;
	}

	/**
	 * 设置主键id
	 * 
	 * @param id
	 *            主键id
	 */
	public void setId(Integer id) {
		this.id = id;
	}

	/**
	 * 取得用户ID
	 * 
	 * @return 用户ID
	 */
	public String getUserID() {
		return this.userID;
	}

	/**
	 * 设置用户ID
	 * 
	 * @param userID
	 *            用户ID
	 */
	public void setUserID(String userID) {
		this.userID = userID;
	}

	/**
	 * 取得密码
	 * 
	 * @return 密码
	 */
	public String getPassword() {
		return this.password;
	}

	/**
	 * 设置用户密码
	 * 
	 * @param password
	 *            用户密码
	 */
	public void setPassword(String password) {
		this.password = password;
	}

	/**
	 * 取得用户身份标识
	 * 
	 * @return 身份标识
	 */
	public Integer getIdentity() {
		return this.identity;
	}

	/**
	 * 设置用户身份标识
	 * 
	 * @param identity
	 *            省份标识
	 */
	public void setIdentity(Integer identity) {
		this.identity = identity;
	}

	/**
	 * @param createDateTime
	 *            创建日期
	 */
	public void setCreateDateTime(Date createDateTime) {
		this.createDateTime = createDateTime;
	}

	/**
	 * @return the createDateTime 创建日期
	 */
	public Date getCreateDateTime() {
		return createDateTime;
	}

	/**
	 * @param lastLoginDateTime
	 *            最后一次登录日期
	 */
	public void setLastLoginDateTime(Date lastLoginDateTime) {
		this.lastLoginDateTime = lastLoginDateTime;
	}

	/**
	 * @return the lastLoginDateTime 最后一次登录日期
	 */
	public Date getLastLoginDateTime() {
		return lastLoginDateTime;
	}

	/**
	 * @param name
	 *            the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param sex
	 *            the sex to set
	 */
	public void setSex(boolean sex) {
		this.sex = sex;
	}

	/**
	 * @return the sex
	 */
	public boolean getSex() {
		return sex;
	}

	/**
	 * @param birthday
	 *            the birthday to set
	 */
	public void setBirthday(Date birthday) {
		this.birthday = birthday;
	}

	/**
	 * @return the birthday
	 */
	public Date getBirthday() {
		return birthday;
	}

	/**
	 * @param email
	 *            the email to set
	 */
	public void setEmail(String email) {
		this.email = email;
	}

	/**
	 * @return the email
	 */
	public String getEmail() {
		return email;
	}

	/**
	 * @param status
	 *            the status to set
	 */
	public void setStatus(boolean status) {
		this.status = status;
	}

	/**
	 * @return the status
	 */
	public boolean getStatus() {
		return status;
	}

	/**
	 * @param ip
	 *            the ip to set
	 */
	public void setIp(String ip) {
		this.ip = ip;
	}

	/**
	 * @return the ip
	 */
	public String getIp() {
		return ip;
	}

}
